import { request } from "./request";
//请求用户数据
export function getUserList(query,pagenum,pagesize){
    return request ({
        method: "get",
        url:'/users',
        params: {
            query,
            pagenum,
            pagesize
          }
    })
}
//更改用户状态
export function setUsersStatus(uid, type) {
    return request({
      method: 'put',
      url:  `users/${uid}/state/${type}`,
      params:{
          uid,
          type
      }
    })
  }
//添加用户
export function addUser(username,password,email,mobile){
    return request({
      method: 'post',
      url:'/users',
      //携带参数必须写
      data:{
        username,
        password,
        email,
        mobile
      }
    })
}
//编辑用户
export function editUser(id){
  return request({
    method:'get',
    url:`users/${id}`,
    params:{
      id
    }
  })
}
//提交编辑用户
export function submit(id,email,mobile){
  return request({
    method:'put',
    url:`users/${id}`,
    data:{
      id,
      email,
      mobile
    }
  })
}
//删除用户
export function removeUser(id){
  return request({
    method:'delete',
    url:`users/${id}`
  })
}
//角色列表
export function getRoleList(){
  return request({
    method:'get',
    url:'/roles'
  })
}
//分配新角色
export function setNewRole(id,rid){
  return request({
    method:'put',
    url:`users/${id}/role`,
    data:{
      rid
    }
  })
}